package com.yz.app.sale.presenter;

import com.yz.app.sale.base.BasePresenter;
import com.yz.app.sale.entity.ArticleEntity;
import com.yz.app.sale.entity.ResultEntity;
import com.yz.app.sale.model.ModelFactory;
import com.yz.app.sale.utils.AppConfig;
import com.yz.app.sale.view.impl.FindViewImpl;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * ----------BigGod be here!----------/
 * ***┏┓******┏┓*********
 * *┏━┛┻━━━━━━┛┻━━┓*******
 * *┃             ┃*******
 * *┃     ━━━     ┃*******
 * *┃             ┃*******
 * *┃  ━┳┛   ┗┳━  ┃*******
 * *┃             ┃*******
 * *┃     ━┻━     ┃*******
 * *┃             ┃*******
 * *┗━━━┓     ┏━━━┛*******
 * *****┃     ┃神兽保佑*****
 * *****┃     ┃代码无BUG！***
 * *****┃     ┗━━━━━━━━┓*****
 * *****┃              ┣┓****
 * *****┃              ┏┛****
 * *****┗━┓┓┏━━━━┳┓┏━━━┛*****
 * *******┃┫┫****┃┫┫********
 * *******┗┻┛****┗┻┛*********
 * ━━━━━━神兽出没━━━━━━
 *
 * 项目名称：Sale
 * 类描述：
 * 创建人：zhangwei
 * 创建时间：2016-07-03 12:06
 * 修改人：zhangwei
 * 修改时间：2016-07-03 12:06
 * 修改备注：
 */

public class FindPresenter extends BasePresenter<FindViewImpl> {

    public void getFindHomeData() {
        ModelFactory.getFindModel()
                .getFindArticleData(new Callback<ResultEntity<ArticleEntity>>() {
                                        @Override
                                        public void onResponse(Call<ResultEntity<ArticleEntity>> call, Response<ResultEntity<ArticleEntity>> response) {
                                            ResultEntity<ArticleEntity> entity = response.body();
                                            if (entity != null && entity.getErrorCode().equals(AppConfig.STATE_SUCCESS)) {
                                                entity.getData().getRows();
                                                getView().onSuccess();
                                            }
                                        }

                                        @Override
                                        public void onFailure(Call<ResultEntity<ArticleEntity>> call, Throwable t) {
                                            System.out.println("");
                                        }
                                    }

                );

    }


}
